import {ipcMain} from "electron";
import {useBrowserHandle} from "../handle/browserHandle";
import {useDbHandle} from "../handle/dbHandle";
import {useFileHandle} from "../handle/fileHandle";
import {useMainHandle} from "../handle/mainHandle";
import {usePrintHandle} from "../handle/printHandle";
import {useUpdateHandle} from "../handle/updateHandle";
import {useServerHandle} from "../handle/serverHandle";

import {IpcMainHandle} from "../ipc";

const ipcMainHandle: IpcMainHandle = {
	...useMainHandle(),
	...useBrowserHandle(),
	...useDbHandle(),
	...useFileHandle(),
	...usePrintHandle(),
	...useServerHandle(),
	...useUpdateHandle(),
};

export function installIpcMain() {
	Object.entries(ipcMainHandle).forEach(([ipcChannelName, ipcListener]) => {
		ipcMain.handle(ipcChannelName, ipcListener);
	});
}
